home *** CD-ROM | disk | FTP | other *** search
/ The Games Machine 76 / XENIATGM66.iso / Indiana Jones / Indiana Jones.exe / RESOURCE / PREVIEW.GOB / cog_pru_boulderfall.cog < prev    next >
Text File  |  1999-11-15  |  17KB  |  569 lines

  1. # Jones 3D Cog Script
  2. #
  3. # PRU_boulderfall.cog    Boulder falls straight down and smashes Indy.
  4. #
  5. # [GGJ]
  6. #
  7. # (C) 1998 LucasArts Entertainment Company LLC. All Rights Reserved
  8. #
  9. # ========================================================================================
  10. symbols
  11.  
  12. message     startup
  13. message     entered
  14. message        touched
  15. message        arrived
  16. message        damaged
  17. message        pulse
  18.  
  19. cog            voicelineWE
  20.                      
  21. thing       player          local
  22. thing        deadindy        local        nolink           
  23. thing       rubble            mask=0x08
  24. thing       boulder
  25. thing        debris
  26. thing         camera0
  27. thing        camera1
  28. thing        camera2
  29. thing        camera3
  30. thing        camera4
  31. thing        fallingrubble    local
  32. thing        smashedghost
  33. thing        columnTarget0
  34. thing        columnTarget1
  35. thing        columnTarget2
  36. thing        columnTarget3
  37. thing        whipCam
  38. thing        fallTarget0
  39. thing        smokeGhost0
  40. thing        smoke0            local
  41. thing        smokeGhost1
  42. thing        smoke1            local
  43. thing        hangTarget
  44. thing        standboulder    local
  45. thing        cam1spot    nolink # ghost anywhere in a level
  46. thing        cam1look    nolink # ghost anywhere in a level
  47. thing        phonyGhost
  48.  
  49.  
  50. surface        skull0            linkID=4
  51. surface        entry
  52. surface        boulderplatform0
  53. surface        boulderplatform1
  54. surface        boulderLedge
  55. surface        exitLedge
  56. surface        cubbyLedge
  57. surface        rubbleFace        mask=0x08
  58.  
  59. sector        columnbottom    mask=0x080
  60.  
  61. keyframe    smashed=in_die_buckle.key                    local
  62.  
  63. sound        sndDie=tem_temspikes_up_kill_c.wav            local
  64. sound        bldrshift=teo_teobut_pull_c.wav                local
  65. sound        debrisfall=tem_tikidoor_tikikeymove_c.wav    local
  66. sound        boulderfall=pru_boulder_crash_c.wav            local
  67. sound        rubblefall=olv_rockhead_hitearth_c.wav        local
  68. sound        triggeredSound=olv_presswitch_c.wav            local
  69. sound        eagleFallsnd=gen_fallingrock_c.wav            local
  70. sound        successMus=mus_gen_indyrelief.wav            local
  71. sound        danger=inxj057.wav                            local
  72. sound        uhoh=INXJ011.wav                            local
  73. sound        whoops=INXJ087.wav                            local
  74.  
  75.  
  76. template    tempRef=indy_sh_actor                           local
  77. template    fallrbletemplate=physrbl                    local                        
  78. template    standbouldertpl=bldrsmash                    local
  79. template    smoketemplate=+bouldersmoke_spr                local
  80. template    phonyTpl=bldrnvelop                            local
  81.  
  82. template    debris0=stoneshrapa    local
  83. template    debris1=stoneshrapb    local
  84. template    debris2=stoneshrapc    local
  85.  
  86.  
  87. int            once=0        local    
  88. int            deadIndy    local
  89. int            curCam        local
  90. int            indy        local
  91. int            fallen=0    local
  92. int            hit=0        local
  93. int            tempCam        local
  94. int            fragment    local
  95. int            i            local
  96. int            triggered=0    local
  97. int            coin        local
  98. int            multiplier    local
  99. int            boulderDown=0    local
  100. int            vibe        local
  101. int            dangerTrack=-1    local
  102.  
  103. vector        posOffset    local
  104. vector        angOffset    local
  105.  
  106. flex        posDelta=100.0    local
  107. flex        angDelta=180.0    local
  108. flex        shakerandom        local
  109. flex        viewangle        local
  110. flex        boulderSize        local
  111.  
  112. end
  113.  
  114. # ========================================================================================
  115. code
  116. startup:
  117.     player = GetLocalPlayerThing();
  118.     ClearSurfaceFlags(exitLedge, 0x1000000);
  119.     ClearSurfaceFlags(cubbyLedge, 0x1000000);
  120.     SetCollideType(rubble, 0);
  121.     boulderSize = GetThingCollideSize(boulder);
  122.     SetCollideType(boulder, 1);
  123.     SetThingCollideSize(boulder, (bouldersize * 0.75));
  124.     
  125.     return;
  126. # =========================================================================================
  127. entered:
  128.     if ((GetSenderRef() == entry) && (once == 0) && (boulderDown == 0))
  129.     {
  130.         once = 1;
  131.         curCam = GetCurrentCamera();
  132.         ResetCameraFOV(0, 0.0);
  133.  
  134.         StartCutscene(1);
  135.         
  136.         #Stop the player from moving and put him in a standing position
  137.         SetActorFlags(player, 0x200000);
  138.         StopThing(player);
  139.         MakeMeStop();
  140. //        PlayMode(player, 1, 0);
  141. //        DeselectWeapon(player);
  142.         DeselectWeaponWait(player);
  143.         
  144.         #create an actor
  145.         indy = CreateThing(TempRef, player);
  146.         CaptureThing(indy);
  147.         AISetCutsceneMode(indy);
  148.         CopyPlayerHolsters(player, indy);
  149.         SetThingFlags(player, 0x80000);
  150.         ClearThingFlags(indy, 0x80000);
  151.         AISetMoveSpeed(indy, 1.0);
  152.         
  153.         #set a camera looking at the actor
  154.         SetCameraLookInterp(2, 0);
  155.         SetCameraPosInterp(2, 0);
  156.         SetCameraFocus(2, camera0);
  157.         SetCameraSecondaryFocus(2, columnTarget3);
  158.         SetCurrentCamera(2);
  159.         SetCameraFOV(90, 0, 0.0);
  160.         
  161.         #Walk the actor to the column
  162.         AIEnableBodyTracking(indy, columnTarget2);
  163.         #AISetlookThing(indy, columnTarget2);
  164.         AISetMoveThing(indy, columnTarget2, 1);
  165.         
  166.         #Indy knocks the debris onto the trigger plate on the floor
  167.         SetCameraLookInterp(2, 1);
  168.         SetCameraPosInterp(2, 1);
  169.         SetCameraInterpSpeed(2, 1.0);                    #was 2
  170.  
  171.         Sleep(0.1);                                        #was .3
  172.         MoveToFrame(debris, 1, 2);                        #was 1
  173.         PlaySoundThing(debrisfall, debris, 1.0, -1.0, -1.0, 0x0);
  174.         
  175.         Sleep(0.2);
  176.         SetCameraFOV(40, 1, 0.75);                        #was 1.0
  177.         
  178.         SetCameraSecondaryFocus(2, columnTarget0);
  179.         
  180.         Sleep(1.0);
  181.  
  182.         SetCameraFOV(70, 1, 5.0);
  183.         WaitForStop(debris);
  184.         Sleep(0.2);
  185.         AISetLookThing(indy, debris);
  186.         if (RandBetween(0, 1) == 0)
  187.         {
  188.             PlayVoice(indy, uhoh, 1, 0);
  189.         }
  190.         else
  191.         {
  192.             PlayVoice(indy, whoops, 1, 0);
  193.         }
  194.         MoveToFrame(debris, 2, 5);
  195.         MoveToFrame(columnTarget0, 1, 3.5);                #was 4.0
  196.         return;
  197.     }
  198.  
  199.     if ((GetSourceRef() == player) && ((GetSenderID() == 4) || (GetSenderRef() == debris)))
  200.     { 
  201.         if (boulderDown == 1) return;
  202.         if ((once == 0) && (GetSenderRef() == debris)) return;
  203.  
  204.         PlaySoundThing(triggeredSound, player, 1.0, -1.0, -1.0, 0x0);
  205.         triggered=1;
  206.         PlaySoundThing(boulderfall, boulder, 0.0, -1.0, -1.0, 0x0);            #play sound at 0 to lessen hitching...
  207.         
  208.         #Indy steps on the trigger plate, causing the boulder to fall on him
  209.         StartCutscene(1);
  210.         SetCameraFocus(2, camera1);
  211.         SetCameraSecondaryFocus(2, fallTarget0);
  212.         SetCurrentCamera(2);
  213.         SetCameraFOV(90, 1, 1.0);
  214.         MoveToFrame(boulder, 3, 20);
  215.         Sleep(2.0);
  216.         posOffSet = VectorSet(0.0, 0.0, 0.0);
  217.         angOffSet = VectorSet(7, RandBetween(-2, 2), RandBetween(-2, 2));
  218.         SetPOVShake(posOffSet, angOffSet, posDelta, angDelta);
  219.         Sleep(1.5);
  220.         EndCutscene();                      
  221.         return;
  222.     }
  223.      
  224.     #when the rubble falls on the skull face, the boulder will fall
  225.     if (GetSourceRef() == fallingRubble)
  226.     {
  227.         SetThingVel(fallingRubble, '0.0 0.0 0.0');
  228.         PlaySoundThing(rubblefall, fallingRubble, 1.0, -1.0, -1.0, 0x0);
  229.         PlaySoundThing(triggeredSound, fallingRubble, 1.0, -1.0, -1.0, 0x0);
  230.         Sleep(0.5);
  231.         
  232.         SetCameraLookInterp(2, 0);
  233.         SetCameraSecondaryFocus(2, boulder);
  234.         SetCameraFOV(100, 0, 0.0);
  235.         Sleep(1.0);
  236.         
  237.         MoveToFrame(boulder, 3, 20);
  238.         PlaySoundThing(bldrshift, boulder, 1.0, -1.0, -1.0, 0x0);
  239.         triggered=1;
  240.         fallen = 1;
  241.         once = 1;
  242.         return;
  243.     }
  244.     
  245.     #Boulder shifts frighteningly if player hangs from ledge under it.
  246.     if ((GetSenderRef() == boulderLedge) && (fallen == 0))
  247.     {
  248.         StartCutscene(0);
  249.         Sleep(0.5);
  250.         SetActorFlags(player, 0x200000);
  251.  
  252.         MakeCamera2LikeCamera1(cam1spot, cam1look);
  253.         SetCameraLookInterp(2, 0);             # force snap if not sure already the case
  254.         SetCameraPosInterp(2, 0);             # force snap if not sure already the case
  255.         SetCameraFocus(2, cam1spot);         # cam 2 takes over here
  256.         SetCameraSecondaryFocus(2, cam1look); # looking same place
  257.         #viewangle = GetCameraFOV();         # it pays to be careful
  258.         SetCurrentCamera(2);
  259.         ResetCameraFOV(0, 0.0);
  260.         #SetCameraFOV(viewangle, 0, 0.0);     # start here anyway
  261.         SetCameraLookInterp(2, 1);
  262.         SetCameraPosInterp(2, 1);
  263.         SetCameraInterpSpeed(2, 0.7);         # about right
  264.         Sleep(0.01);                         # let engine work briefly
  265.         #SetCameraFocus(2, offsetcam);         # slide out to new spot
  266.         SetCameraSecondaryFocus(2, hangTarget); # slide over to new target
  267.         
  268.         #SetExtCamLookOffsetToThing(hangTarget);
  269.         Sleep(1.0);
  270.         SetPulse(0.01);
  271.  
  272. #        posOffSet = VectorSet(RandBetween(-1, 1) * 0.001, RandBetween(-1, 1) * 0.001, RandBetween(-1, 1) * 0.001);
  273. #        angOffSet = VectorSet(RandBetween(-1, 1) * 0.01, RandBetween(-1, 1) * 0.01, RandBetween(-1, 1) * 0.01);
  274. #        Sleep(0.5);
  275.         MoveToFrame(Boulder, 2, 1.0);
  276.         PlaySoundThing(bldrshift, boulder, 1.0, -1.0, -1.0, 0x0);
  277. #        SetPOVShake(posOffSet, angOffSet, posDelta, angDelta);
  278. #        Sleep(0.05);
  279. #        SetPOVShake(posOffSet, angOffSet, posDelta, angDelta);
  280. #        Sleep(0.05);
  281. #        SetPOVShake(posOffSet, angOffSet, posDelta, angDelta);
  282. #        Sleep(1.0);
  283.         Sleep(1.0);
  284.         SetPulse(0.0);
  285.         
  286.         SetCameraInterpSpeed(2, 0.5); # quicker going back, please
  287.         SetCameraSecondaryFocus(2, cam1look);
  288.         #SetCameraFOV(viewangle, 1, 0.5); # transition back to follow-cam FOV
  289.         Sleep(0.5);
  290.         SetCameraLookInterp(2, 0); # exit in snap mode
  291.         SetCameraPosInterp(2, 0); # exit in snap mode
  292.         SetCurrentCamera(1);
  293.         
  294.         #RestoreExtCam();
  295.         ClearActorFlags(player, 0x200000);
  296.         EndCutscene();
  297.         return;
  298.     }
  299.         
  300.     return;
  301. # =========================================================================================
  302. arrived:
  303.     if ((GetSenderRef() == debris) && (GetCurFrame(debris) == 1))
  304.         {
  305.             #angOffSet = VectorSet(0.05, 0.05, 0.05);
  306.             #PlaySoundThing(debrisfall, debris, 1.0, -1.0, -1.0, 0x0);
  307.             Call ShakeRandom;
  308.             Sleep(0.01);
  309.             SetPOVShake(posOffSet, angOffSet, posDelta, angDelta);
  310.             Sleep(0.05);
  311.             Call ShakeRandom;
  312.             SetPOVShake(posOffSet, angOffSet, posDelta, angDelta);
  313.         }
  314.  
  315.     if ((GetSenderRef() == debris) && (GetCurFrame(debris) == 2))
  316.         {
  317.             #Sleep(0.75);
  318.             #SetCameraFOV(70, 1, 2.0);
  319.             
  320.             #Debris hits the floor, triggering the boulder
  321.             PlaySoundThing(rubbleFall, debris, 0.7, -1.0, -1.0, 0x0);
  322.             Sleep(0.75);
  323.             PlaySoundThing(triggeredSound, debris, 1.0, -1.0, -1.0, 0x0);
  324.             
  325.             #shake the camera as the trap is partially triggered
  326.             #angOffSet = VectorSet(0.1, 0.1, 0.1);
  327.             #posOffSet = VectorSet(0.01, 0.01, 0.01);
  328.             SetPOVShake(posOffSet, angOffSet, posDelta, angDelta);
  329.             Call ShakeRandom;
  330.             Sleep(0.025);
  331.             SetPOVShake(posOffSet, angOffSet, posDelta, angDelta);
  332.             Call ShakeRandom;
  333.             Sleep(0.025);
  334.             SetPOVShake(posOffSet, angOffSet, posDelta, angDelta);
  335.             Call ShakeRandom;
  336.             Sleep(0.025);
  337.             SetPOVShake(posOffSet, angOffSet, posDelta, angDelta);
  338.             Call ShakeRandom;
  339.             Sleep(0.025);
  340.             SetPOVShake(posOffSet, angOffSet, posDelta, angDelta);
  341.             
  342.             Sleep(0.75);
  343.             
  344.             SetCameraLookInterp(2, 1);
  345.             SetCameraPosInterp(2, 1);
  346.             SetCameraInterpSpeed(2, 2.5);
  347.             Sleep(0.1);
  348.             SetCameraSecondaryFocus(2, columnTarget1);
  349.             Sleep(0.5);
  350.             
  351.             SetCameraFocus(2, camera3);
  352.             #SetCameraSecondaryFocus(2, columnTarget1);
  353.             SetCurrentCamera(2);
  354.             #MoveToFrame(columnTarget1, 1, 0.8);
  355.             
  356.             
  357.             MoveToFrame(boulder, 1, 0.2);
  358.             AISetLookThing(indy, boulder);
  359.             Sleep(2.0);
  360.             
  361.             PlaySoundThing(bldrshift, boulder, 1.0, -1.0, -1.0, 0x0);
  362.             posOffset = VectorSet(Rand()*0.1, Rand()*0.1, Rand()*0.1);
  363.             angOffset = VectorSet(Rand(), Rand(), Rand());
  364.             #SetPOVShake(posOffset, angOffset, .5, 80.0);
  365.             
  366.             Sleep(2.5);
  367.             
  368.             ResetCameraFOV(0, 0.0);
  369.             SetCameraLookInterp(2, 0);
  370.             SetCameraPosInterp(2, 0);
  371.             CopyOrientandPos(indy, player);
  372.             tempCam = GetThingPos(camera4);
  373.             SetCameraPosition(curcam, tempCam);
  374.             SetCurrentCamera(curCam);
  375.             SetThingFlags(indy, 0x80000);
  376.             ClearThingFlags(player, 0x80000);
  377.             ClearActorFlags(player, 0x200000);
  378.             if (boulderdown != 1)
  379.             {
  380.                 dangerTrack = PlayVoice(player, danger, 1, 0);
  381.             }
  382.             
  383.             
  384.             #debugprint("leaving boulder arrived");
  385.             
  386.             EndCutscene();
  387.         }
  388.  
  389. if ((GetSenderRef() == boulder) && (GetCurFrame(boulder) == 3))
  390. {
  391.     if (dangerTrack != -1)
  392.     {
  393.         StopSound(dangerTrack, 0.0);
  394.         dangerTrack = -1;
  395.     }
  396.     boulderDown = 1;
  397.     once = 1;
  398.     PlaySoundThing(boulderfall, boulder, 1.0, -1.0, -1.0, 0x0);
  399.     posOffSet = VectorSet(0.0, 0.0, 0.25);
  400.     angOffSet = VectorSet(0, 0, 0);
  401.     SetPOVShake(posOffSet, angOffSet, 6.0, angDelta);
  402.     #ClearAdjoinFlags(boulderplatform0, 0x2);
  403.     #ClearAdjoinFlags(boulderplatform1, 0x2);
  404.     SetAdjoinFlags(boulderplatform0, 0x10);
  405.     SetAdjoinFlags(boulderplatform1, 0x10);
  406.  
  407.     
  408.     smoke0 = CreateThing(smoketemplate, smokeGhost0);
  409.     AnimateSpriteSize(smoke0, '0.25 0.25 1.0', '0.75 0.75 0.0', 3.0);
  410.     
  411.     smoke1 = CreateThing(smoketemplate, smokeGhost1);
  412.     AnimateSpriteSize(smoke1, '0.25 0.25 1.0', '0.75 0.75 0.0', 3.0);
  413.     
  414.     
  415.     
  416.     for(i=0; i<20; i=i+1)                                                                        
  417.     {
  418.         fragment = CreateThing(debris0[3.0 * rand()], smokeghost1);
  419.         SetThingVel(fragment, VectorScale(VectorAdd(RandVec(), '-0.5 -0.5 0.05'), 2.0));
  420.         SetThingRotVel(fragment, VectorScale(VectorAdd(RandVec(), '0.0 0.0 0.0'), 900.0));                    
  421.     }
  422.     
  423.     
  424.     standBoulder = CreateThing(standbouldertpl, smashedghost);
  425.     SetCameraSecondaryFocus(2, standBoulder);
  426.     DestroyThing(boulder);
  427.     CaptureThing(standBoulder);
  428.     SetCollideType(standBoulder, 0);
  429.     CreateThing(phonyTpl, phonyGhost);
  430.     Sleep(3.0);
  431.     SetCurrentCamera(curCam);
  432.     ResetCameraFOV(0, 0.0);
  433.     SetSurfaceFlags(exitLedge, 0x1000000);
  434.     SetSurfaceFlags(cubbyLedge, 0x1000000);
  435.  
  436.     ClearActorFlags(player, 0x200000);
  437.     EndCutscene();
  438.  
  439.     return;
  440. }
  441. return;
  442. # =========================================================================================
  443. touched:
  444.     if ((GetSenderRef() == boulder) && (GetSourceRef() == player) && (fallen == 0) && (triggered == 1))
  445.     {
  446.         #Print("boulder touched player");
  447.         DamageThing(player, 1000, 0x80, boulder);
  448.         SetCollideType(boulder, 0);
  449.         PlaySoundLocal(sndDie, 1.0, 0.0, 0x0, 0);
  450.         StartCutscene(1);
  451.         SetCameraFocus(2, camera2);
  452.         SetCameraSecondaryFocus(2, smashedGhost);
  453.         SetCurrentCamera(2);
  454.         SetCameraFOV(90, 1, 1.0);
  455.         Sleep(1.0);
  456.         posOffset = VectorSet(Rand()*0.01, Rand()*0.01, Rand()*0.01);
  457.         angOffset = VectorSet(Rand(), Rand(), Rand());
  458.         SetPOVShake(posOffset, angOffset, .5, 80.0);
  459.         Sleep(1.5);
  460.         EndCutscene();    
  461.     }
  462.     return;
  463.  
  464. # ========================================================================================
  465. damaged:
  466.     
  467.     if (hit == 1) return;
  468.  
  469.     
  470.     if ((GetSenderRef() == rubbleFace) && (GetParam(1) == 0x10))
  471.     {
  472.         #tell the voiceline cog to shut down.
  473.         SetCollideType(rubble, 1);
  474.         SendMessage(voiceLineWE, user0);
  475.         hit = 1;
  476.         fallen = 1;
  477.         
  478.         StartCutscene(1);
  479.         SetActorFlags(player, 0x200000);
  480.         
  481.         curCam = GetCurrentCamera();
  482.         
  483.         fallingRubble = CreateThing(fallrbletemplate, rubble);
  484.         CaptureThing(fallingRubble);
  485.         SetThingMass(fallingRubble, 4.0);
  486.         DestroyThing(rubble);
  487.         
  488.         SetCameraFocus(2, whipCam);
  489.         #SetCameraSecondaryFocus(2, rubble);
  490.         SetCurrentCamera(2);
  491.         SetCameraSecondaryFocus(2, fallingRubble);
  492.         
  493.         Sleep(0.5);
  494.         
  495.         PlaySoundLocal(successMus, 1.0, 0.0, 0x0, 0);
  496.         
  497.         DetachThing(fallingrubble);
  498.         ApplyForce(fallingrubble, '-1.0 -2.0 1.0');
  499.         PlaySoundLocal(eagleFallSnd, 1.0, 0.0, 0x0, 0);
  500.         Sleep(0.1);
  501.         ApplyForce(fallingrubble, '0.0 0.0 -3.0');
  502.         SetThingMass(fallingRubble, 100.0);
  503.         SetPhysicsFlags(fallingRubble, 0x41);
  504.         PlaySoundThing(boulderfall, boulder, 0.0, -1.0, -1.0, 0x0);            #play sound at 0 to lessen hitching...
  505.         
  506.     }
  507.     return;
  508.     
  509. # ======================================================================================== 
  510. pulse:
  511. if (boulderdown == 1)
  512. {
  513.     smoke0 = CreateThing(smoketemplate, smokeGhost0);
  514.     AnimateSpriteSize(smoke0, '0.01 0.01 1.0', '0.3 0.3 0.0', 2.0);
  515.     return;
  516. }
  517.  
  518. vibe = randBetween(1, 4);
  519.  
  520. if (vibe == 1)
  521. {
  522.     posOffset = '-0.002 0.00 -0.001';
  523.     angOffset = '0.00 -0.001 0.001';
  524. }
  525. if (vibe == 2)
  526. {
  527.     posOffset = '0.002 -0.002 0.001';
  528.     angOffset = '0.001 0.00 -0.001';
  529. }
  530. if (vibe == 3)
  531. {
  532.     posOffset = '0.001 0.002 -0.002';
  533.     angOffset = '-0.001 0.001 -0.001';
  534. }
  535. if (vibe == 4)
  536. {
  537.     posOffset = '-0.001 0.00 0.002';
  538.     angOffset = '0.00 0.00 0.001';
  539. }
  540.  
  541. SetPOVShake(posOffSet, angOffSet, 200.0, 200.0);
  542.  
  543. return;
  544.  
  545. # ======================================================================================== 
  546. ShakeRandom:
  547. coin=Randbetween(1, 2);
  548. if (coin == 1)
  549. {
  550.     multiplier = 1;
  551. }
  552. else
  553. {
  554.     multiplier = -1;
  555. }
  556.  
  557. posOffSet = VectorSet(multiplier * 0.007, multiplier * 0.007, multiplier * 0.007);
  558. angOffSet = VectorSet(multiplier * 0.07, multiplier * 0.07, multiplier * 0.07);
  559. #Print("posOffSet=");
  560. #PrintVector(posOffSet);
  561. #Print("angOffSet=");
  562. #PrintVector(angOffSet);
  563.  
  564. return;
  565.  
  566.  
  567. end
  568. # ======================================================================================== 
  569.